
#ifndef _OPTIMFS_H
#define _OPTIMFS_H

#define FUSE_USE_VERSION 26

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifdef linux
/* For pread()/pwrite() */
#define _XOPEN_SOURCE 500
#endif

#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
#include <sys/time.h>
#include <glob.h>
#include <sqlite3.h>
#include <time.h>
#ifdef HAVE_SETXATTR
#include <sys/xattr.h>
#endif

#include "common.h"
#include "util.h"
#include "id3TagParser.h"
#include "sqliteDataProvider.h"
#include "configReader.h"
#include "exifTagParser.h"
#include "customTagParser.h"

int mp3listsize;
List_t mp3list;

#define MP3 1
#define EXIF 2
#define STAT 3
#define CUSTOM 4

typedef struct open_files_t
 {
         int fd;
         char *path;
         struct open_files_t *next;
 } open_files;
 open_files *fileHead;
 open_files *fileTail;


//extern void getInfo(char *filename,char *fileInfo);
int readConfigFile(char *configFilePath);
int getFileInfo();
int FindFolderInfo(char *currPath);
int readFileData(char *path,int isUpdate = 0);
int getFilePath(char *path,char **filePath);
int FindMusicFolders(const char *path, void *buf,fuse_fill_dir_t filler);
int getLevelKeys(char ***level_key,const char *path);
void printMp3List(List_t *list);
int callback(void *NotUsed, int argc, char **argv, char **azColName);
int fillData(void *fillInfo, int argc, char **argv, char **azColName);
char *formSearchQuery(int numLevels,char **level_key,int indexFolderInfo,char *columnName,int *isLastFolder = 0);
char *prepareQuery(const char *path,char *columnName, int *isLastFolder = 0);
void freeLevelKeys(char **level_key);


//list of open files
sqlite3 *db;
#define MAX_LEVEL 2 //temp..change to make more dynamic.

typedef struct folderstruct_t
 {
	char folderName[1024];
	arraycontainer *rules;
	char sourcePath[1024];
	char tableName[512];
	arraycontainer *tagList;
 }folderstruct;
 
 typedef struct folderList_t
 {
	folderstruct **folderData;
	int numFolders;
 }folderList;
 
 folderList folderInfo;
 
#endif
